# Contributor: Galen Abell <galen@galenabell.com>
# Maintainer: Galen Abell <galen@galenabell.com>
pkgname=py3-icalendar
_pyname=icalendar
pkgver=6.0.1
pkgrel=0
pkgdesc="icalendar parser library for Python"
url="https://github.com/collective/icalendar"
arch="noarch"
license="BSD-2-Clause"
depends="py3-dateutil tzdata"
makedepends="py3-gpep517 py3-hatchling py3-hatch-vcs py3-wheel"
checkdepends="py3-pytest py3-hypothesis py3-tz"
subpackages="$pkgname-pyc"
source="$_pyname-$pkgver.tar.gz::https://github.com/collective/icalendar/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/$_pyname-$pkgver"

build() {
	export SETUPTOOLS_SCM_PRETEND_VERSION="$pkgver"
	# Hatch VCS supports adding formattable URLs to the version data, but the `commit_hash` field requires a git repo.
	sed -i '/{commit_hash}/d' pyproject.toml
	gpep517 build-wheel \
		--wheel-dir dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --system-site-packages testenv
	testenv/bin/python3 -m installer dist/*.whl
	# Test fails on arm7 pipeline for some reason but isn't reproducible locally.
	testenv/bin/python3 -m pytest "src/$_pyname/tests" \
		--deselect 'src/icalendar/tests/test_unit_cal.py::test_calendars_with_same_subcomponents_in_different_order_are_equal[issue_526_calendar_with_events-issue_526_calendar_with_shuffeled_events]'
}

package() {
	python3 -m installer -d "$pkgdir" \
		dist/*.whl

	rm -r "$pkgdir"/usr/lib/python*/site-packages/icalendar/tests/
}

sha512sums="
aa8ff3673f3f9ddde1512d5b1268b4d9dc7ac5c181eea0766e9fb51f9b9cf7dcbdd26877ed78f626af70cd586c471950a35dbba572e97016ded3655d74399c59  icalendar-6.0.1.tar.gz
"
